<template>
	<view class="cflex_items">
		<view class="top_items">
			<view class="left_text">已发货</view>
			<view class="right_text">
				<image src="../../static/clq-image/yifahuo_1@3x.png" class="images" mode=""></image>
			</view>
		</view>
	
		<view class="detail cflex cflex_col">
			<view class="top cflex cflex_row">
				<image :src="image" mode=""></image>
				<view class="cflex cflex_col">
					<view class="againItem-name">{{goods.name}}</view>
					<view class="againItem-type_name">{{goods.type_name}}</view>
					<view class="againItem-factory_price">￥{{goods.factory_price}}</view>
					<view class="againItem-num">购买件数：{{goods.num}}件</view>
				</view>
			</view>
		</view>
		<view class="orders_info">
			<view class="">订单详情</view>
			<view >订单编号：{{goods.no}}</view>
			<view >创建时间：{{goods.createdate}}</view>
			<view >订单需求：{{goods.num}}件</view>
		</view>
		<view class="fixBlock cflex cflex_row cflex_right cflex_items">
			<view class="fixTip" v-if="goods.status=='101'">财务审核中</view>
			<view class="fixTip" v-if="goods.status=='201'">待发货</view>
			<view class="fixTip" v-if="goods.status=='501'">已完成</view>
			<view class="fixBtnss cflex cflex_row cflex_center cflex_items" v-if="goods.status=='101'">联系客服</view>
			<view class="fixBtns cflex cflex_row cflex_center cflex_items" v-if="goods.status!='101'">联系客服</view>
			<view class="fixBtns cflex cflex_row cflex_center cflex_items" v-if="goods.status=='201'" @click="tixing()">提醒发货</view>
			<view class="fixBtn cflex cflex_row cflex_center cflex_items" v-if="goods.status=='301'">查看物流</view>
			<view class="fixBtns cflex cflex_row cflex_center cflex_items" v-if="goods.status=='501'" @click="evaluate()">去评价</view>
			<view class="fixBtns cflex cflex_row cflex_center cflex_items" v-if="goods.status=='401'" @click="queren()">确认收货</view>
		</view>
	</view>
</template>

<script>
	import {
		ajax
	} from '../../ajax.js';
	export default{
		data(){
			return{
				id:'',
				num:'',
				goods:[],
				address:[],
				image:'',
				remarks:'',
				address_id:''
			}
		},
		onLoad:function(opt){
			let that = this
			 //that.id = opt.id
			 //that.num = opt.num
			 that.id = opt.id
			 that.num = 110
			 that.getDetail()
		},
		methods:{
			tapaddress(){
				let that=this
				uni.navigateTo({
					url:"/pages/addressForm/addressForm?id="+that.id+"&num="+that.num
				})
			},
			evaluate(){
				let that=this
				uni.navigateTo({
					url:"/pages/order/Evaluate?id="+that.id
				})
			},
			addOrder(){
				let that = this
				
			  	that.address_id=that.address[0].address_id
				
				uni.showLoading({
					title: "加载中"
				})
				ajax({
					url: 'order/getOrder',
					data: {
						token: uni.getStorageSync('token'),
						id: that.id,
						num:that.num,
						address_id:that.address_id,
						remarks:that.remarks
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						uni.hideLoading()
						if (res.data.code == 1) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
							uni.navigateTo({
								url:'/pages/orderList/orderList?type=1'
							})
						} else if (res.data.code == 0) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						} else if (res.data.code == -1) {
							uni.reLaunch({
								url: '/pages/clq_login/clq_login'
							})
						} else if (res.data.code == -2) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						}
					},
					error: function() {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					}
				});
			},
			inputText(e){
				this.remarks=e.detail.value
			},
			queren(){
			let that = this
			ajax({
				url: 'order/takeOrder',
				data: {
					token: uni.getStorageSync('token'),
					order_id: that.id
				},
				header: {
					'content-type': 'application/json' //自定义请求头信息
				},
				method: 'POST',
				success: function(res) {
					uni.hideLoading()
					let result = res.data.data
					if (res.data.code == 1) {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					} else if (res.data.code == 0) {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					} else if (res.data.code == -1) {
						uni.reLaunch({
							url: '/pages/clq_login/clq_login'
						})
					} else if (res.data.code == -2) {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
				     	});
						}
					},
					error: function() {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					}
				});
			},
			tixing(){
			    let that = this
				ajax({
					url: 'order/sort',
					data: {
						token: uni.getStorageSync('token'),
						order_id: that.id
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						uni.hideLoading()
						let result = res.data.data
						if (res.data.code == 1) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						} else if (res.data.code == 0) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						} else if (res.data.code == -1) {
							uni.reLaunch({
								url: '/pages/clq_login/clq_login'
							})
						} else if (res.data.code == -2) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						}
					},
					error: function() {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					}
				});
			},
			getDetail(){
				let that = this
				uni.showLoading({
					title: "加载中"
				})
				ajax({
					url: 'order/getOrder',
					data: {
						token: uni.getStorageSync('token'),
						order_id: that.id
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						uni.hideLoading()
						res.data.data.status='501'
						let result = res.data.data
						if (res.data.code == 1) {
							that.goods = result
							//that.address = result.address
							that.image = result.images[0]
						} else if (res.data.code == 0) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						} else if (res.data.code == -1) {
							uni.reLaunch({
								url: '/pages/clq_login/clq_login'
							})
						} else if (res.data.code == -2) {
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						}
					},
					error: function() {
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f7f7f7;
	}
	.ccontainer{
		padding: 0 20rpx;
	}
	.address{
		width: 100%;
		box-sizing: border-box;
		background-color: #fff;
		padding: 20rpx 30rpx;
		border-radius: 20rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
	}
	.address image{
		width: 12rpx;
		height: 20rpx;
	}
	.detail{
		width: 94%;
		box-sizing: border-box;
		background: #ffffff;
		border-radius: 20rpx;
		margin:20rpx auto;
		padding: 2.5%;
	}
	.top{
		padding-bottom: 24rpx;
		border-bottom: 2rpx solid #f7f7f7;
	}
	.top image{
		width: 149rpx;
		height: 149rpx;
		margin-right: 49rpx;
		border-radius: 12rpx;
	}
	.againItem-name{
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
	}
	.againItem-type_name{
		font-size: 24rpx;
		font-weight: 500;
		color: #555555;
		margin: 5rpx 0 10rpx 0;
	}
	.againItem-factory_price{
		font-size: 24rpx;
		font-weight: 500;
		color: #D50000;
	}
	.againItem-num{
		font-size: 28rpx;
		font-weight: 500;
		color: #555555;
		margin-top: 5rpx;
	}
	.bottom{
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		line-height: 50rpx;
	}
	
	.address input{
		width: 100%;
		margin-left: 44rpx;
		font-size: 24rpx;
		font-weight: 500;
	}
	.fixBlock{
		width: 100%;
		box-sizing: border-box;
		height: 100rpx;
		background: #ffffff;
		box-shadow: 0px -5rpx 16rpx 8rpx rgba(177,177,177,0.27); 
		background-color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		padding-right: 20rpx;
	}
	.fixTip{
		font-size: 28rpx;
		font-weight: 500;
		color: #FF7427;
		margin-right: 20rpx;
	}
	.top_items{
		width: 100%;
		padding-top: 20rpx;
		background: #FF7427;
		font-size: 30rpx;
        overflow: hidden;
		.left_text{
			float: left;
			width: 45%;
			margin: 5% auto 5% 5%;
			font-size: 30rpx;
			color: #FFFFFF;
		}
		.right_text{
			text-align: right;
			width: 40%;
			float: right;
			margin-right: 5%;
			.images{
				width:128rpx;
				height: 92rpx;
			}
		}
	}
	.orders_info{
		width: 90%;
		padding: 2.5%;
		margin: 0rpx auto;
		font-size: 30rpx;
		color: #333333;
		background: #FFFFFF;
		border-radius: 20rpx;
		line-height: 58rpx;
	}
	.fixBtn{
		width: 170rpx;
		height: 56rpx;
		background: #ff7427;
		border-radius: 28rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #ffffff;
		margin-right: 20rpx;
	}
	.fixBtns{
		width: 170rpx;
		height: 56rpx;
		background: #fff;
		border: 2rpx solid #FF7427;
		border-radius: 28rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #FF7427;
		margin-right: 20rpx;
	}
	.fixBtnss{
		width: 170rpx;
		height: 56rpx;
		background: #fff;
		border: 2rpx solid #999;
		border-radius: 28rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #999;
		margin-right: 20rpx;
	}
</style>
